package com.hopu.v1.controller.admin.classes;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hopu.v1.pojo.classes.EmploymentInfo;
import com.hopu.v1.pojo.classes.Student;
import com.hopu.v1.pojo.common.R;
import com.hopu.v1.pojo.common.Update;
import com.hopu.v1.service.admin.classes.EmploymentInfoService;
import com.hopu.v1.service.admin.classes.StudentService;
import com.hopu.v1.vo.StudentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 就业管理
 */
@RestController
@RequestMapping("/employment")
public class EmploymentController {

    @Autowired
    private EmploymentInfoService employmentInfoService;

    @Autowired
    private StudentService studentService;

    /**
     * 查询就业信息
     * @param page
     * @param StudentVo
     * @return
     */
    @GetMapping("/selectAll")
    public R selectAll (Page<EmploymentInfo> page, StudentVo StudentVo) {
        System.out.println(StudentVo);
        return R.ok("获取成功",employmentInfoService.selectAll(page, StudentVo));
    }

    /**
     * 根据Id批量删除
     * @param ids
     * @return
     */
    @DeleteMapping("deleteByIds")
    public R deleteByIds (@RequestParam(value = "ids", required = false) List<Long> ids) {
        return R.ok("删除成功！",employmentInfoService.removeByIds(ids));
    }

    /**
     * 添加就业信息
     * @param employmentInfo
     * @return
     */
    @PostMapping("addEmploymentInfo")
    public R addEmploymentInfo (@Validated(Update.class) EmploymentInfo employmentInfo) {
        return employmentInfoService.addEmploymentInfoById(employmentInfo);
    }

    /**
     * 根据Id修改就业信息
     * @param employmentInfo
     * @return
     */
    @PostMapping("updateEmploymentById")
    public R updateEmploymentById (@Validated(Update.class) EmploymentInfo employmentInfo) {
        return employmentInfoService.updateEmploymentInfoById(employmentInfo);
    }
}
